<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>人工智能信息论坛</title>
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400&family=Lato:wght@700&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@700&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=EB+Garamond&display=swap" rel="stylesheet">
    <style>
        body {
            background-image: url('C736.jpg');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            background-attachment: fixed;
            color: white;
            font-family: 'EB Garamond', serif;
            margin: 0;
            padding: 0;
            transition: background-image 1s ease-in-out;
            pointer-events: none; /* 禁用页面交互 */
        }

        /* Logo样式 */
        #logo {
            top: 20px;
            left: 20px;
            width: 100px;
            height: auto;
            z-index: 1500;
            position: relative;
        }

        /*标题*/
        h1 {
            font-size: 85px;
            color: #6F4E8E;
            text-align: center;
            margin: 20px 0;
        }

        /*右上角登录按钮*/
        #greetButton {
            pointer-events: auto; /* 允许点击登录按钮 */
            position: fixed;
            top: 20px;
            right: 20px;
            padding: 10px 20px;
            font-size: 16px;
            /*background-color: transparent;*/
            color: black;
            cursor: pointer;
            transition: color 0.3s;
        }

            #greetButton:hover {
                color: #6F4E8E;
            }

        /* 模态框样式 */
        #modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        #modalContent {
            background-color: rgba(225, 255, 225, 0.4);
            padding: 20px;
            border-radius: 5px;
            text-align: center;
            z-index: 1001;
        }

        #closeButton {
            margin-top: 10px;
        }

        /* 图片轮播样式 */
        #imageCarousel {
            margin: 100px auto;
            width: 80%;
            height: 300px;
            display: flex;
            overflow: hidden;
            border: 2px solid #A3A2A7;
            position: relative;
            cursor: pointer;
        }

        .carousel-image {
            min-width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease, opacity 0.5s ease;
            position: absolute;
            top: 0;
            left: 0;
            opacity: 0;
        }

            .carousel-image.active {
                opacity: 1;
                z-index: 1;
            }

            .carousel-image:hover {
                transform: scale(1.05);
            }

        .arrow {
            cursor: pointer;
            color: #DD21C1;
            font-size: 30px;
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            user-select: none;
            z-index: 10;
        }

        #leftArrow {
            left: 10px;
        }

        #rightArrow {
            right: 10px;
        }

        /* 题目样式 */
        #titles {
            margin: 20px auto;
            width: 80%;
            text-align: center;
            color: white;
        }

        .title-link {
            display: block;
            font-size: 40px;
            margin: 5px 0;
            color: #88B021;
            text-decoration: none;
            transition: color 0.3s;
        }

            .title-link:hover {
                color: #B31111;
            }

        h2 {
            color: green; /* 设置h2字体颜色 */
            font-size: 36px; /* 设置h2字体大小 */
        }

        p {
            color: green; /* 设置p字体颜色 */
            font-size: 20px; /* 设置p字体大小 */
        }
    </style>
</head>
<body>
    <img id="logo" src="logo.jpg" alt="Logo">
    <button id="greetButton">登录/注册</button>
    <h1>欢迎访问人工智能信息论坛</h1>
    <p id="greetingMessage"></p>

    <!-- 模态框 -->
    <div id="modal">
        <div id="modalContent">
            <p>请输入您的昵称：</p>
            <input type="text" id="nameInput" placeholder="您的昵称">
            <p>请输入您的密码：</p>
            <input type="password" id="passwordInput" placeholder="您的密码">
            <p>确认您的密码：</p>
            <input type="password" id="confirmPasswordInput" placeholder="再次输入您的密码">
            <button id="submitButton">登录/注册</button>
            <button id="closeButton">关闭</button>
        </div>
    </div>

    <!-- 图片轮播 -->
    <div id="imageCarousel">
        <div class="arrow" id="leftArrow">&#9664;</div>
        <img class="carousel-image active" src="t133.jpg" alt="Image 1" data-url="ai对未来的影响.html">
        <img class="carousel-image" src="t134.jpg" alt="Image 2" data-url="程序员的未来.html">
        <div class="arrow" id="rightArrow">&#9654;</div>
    </div>

    <!-- 题目链接 -->
    <div id="titles">
        <a href="mp3-1.html" class="title-link">|达沃斯论坛 地区冲突和人工智能成热门议题|</a>
        <a href="222.html" class="title-link">|中国的人工智能与美国相比处在什么水平？超越还是落后？|</a>
        <a href="333.html" class="title-link">|AI发展迅猛，人工智能时代，我们如何才能不被淘汰|</a>
        <a href="mp3-4.html" class="title-link">|AI客服！朱广权：人工+智能才是更好的人工智能|</a>
        <a href="555.html" class="title-link">|龚克披露：人工智能为抗击新型病毒发挥很大作用！|</a>
        <a href="666.html" class="title-link">|人工智能当总统？普京：人造的东西没有感情！|</a>
        <a href="777.html" class="title-link">|未来战争？五角大楼将举行空战大赛，人工智能对阵F-16飞行员|</a>
        <a href="888.html" class="title-link">|如何才能避免被人工智能取代？院士给了他的建议|</a>
        <a href="999.html" class="title-link">|厉害了！我国将建设首个"人工智能星座"由192颗卫星组成|</a>
        <a href="101.html" class="title-link">|AI介入卫生？日本新开发人工智能能监督你正确洗手|</a>
    </div>

    <!-- 用户输入区域 -->
    <div id="userInputSection" style="margin: 40px auto; width: 80%; text-align: center;">
        <input type="text" id="userInput" placeholder="分享自己的想法吧！" style="padding: 10px; font-size: 16px; width: 60%;">
        <button id="confirmInputButton" style="padding: 10px 20px; font-size: 16px; margin-left: 10px; background-color: #9FEC25; color: #8235B6; border: none; border-radius: 5px; cursor: pointer;">发布</button>
    </div>

    <!-- 显示用户输入的内容 -->
    <div id="userInputDisplay" style="margin: 40px auto; width: 60%; text-align: center; color: black;">
        <h2>更多讨论：</h2>
        <p>
            ！仅支持查看最新评论！
        </p>
        <div id="userInputOutput" style="border: 1px solid #A3A2A7; padding: 10px; border-radius: 5px; background-color: #FFFFFF;"></div>
    </div>

    <script>
        const greetButton = document.getElementById('greetButton');
        const modal = document.getElementById('modal');
        const nameInput = document.getElementById('nameInput');
        const passwordInput = document.getElementById('passwordInput');
        const confirmPasswordInput = document.getElementById('confirmPasswordInput');
        const greetingMessage = document.getElementById('greetingMessage');
        const submitButton = document.getElementById('submitButton');
        const closeButton = document.getElementById('closeButton');

        const carouselImages = document.querySelectorAll('.carousel-image');
        let currentImageIndex = 0;

        const backgrounds = ['C736.jpg', 'C735.jpg', 'C734.jpg'];
        let currentBackgroundIndex = 0;

        function changeBackground() {
            document.body.style.backgroundImage = `url('${backgrounds[currentBackgroundIndex]}')`;
            currentBackgroundIndex = (currentBackgroundIndex + 1) % backgrounds.length;
        }

        function showImage(index) {
            carouselImages.forEach((img, i) => {
                img.classList.remove('active');
                if (i === index) {
                    img.classList.add('active');
                }
            });
        }

        function showNextImage() {
            currentImageIndex = (currentImageIndex + 1) % carouselImages.length;
            showImage(currentImageIndex);
        }

        function showPrevImage() {
            currentImageIndex = (currentImageIndex - 1 + carouselImages.length) % carouselImages.length;
            showImage(currentImageIndex);
        }

        // 点击图片跳转
        carouselImages.forEach((img) => {
            img.addEventListener('click', () => {
                const url = img.getAttribute('data-url');
                if (url) {
                    window.location.href = url; // 跳转到指定页面
                }
            });
        });

        document.getElementById('leftArrow').addEventListener('click', showPrevImage);
        document.getElementById('rightArrow').addEventListener('click', showNextImage);

        // 每5秒自动切换图片
        setInterval(showNextImage, 5000);
        // 每7秒更改背景
        setInterval(changeBackground, 7000);

        // 检查用户是否已经登录
        window.onload = function () {
            const savedName = sessionStorage.getItem('username');
            const savedPassword = sessionStorage.getItem('password'); // 获取密码
            if (savedName) {
                greetButton.textContent = savedName; // 更改按钮文本为用户昵称
                greetButton.onclick = function () {
                    // 跳转至用户信息页面，传递用户信息（例如：用户名和密码）
                    window.location.href = `userInfo.html?username=${encodeURIComponent(savedName)}&password=${encodeURIComponent(savedPassword)}`;
                };
                document.body.style.pointerEvents = 'auto'; // 允许页面交互
            } else {
                document.body.style.pointerEvents = 'none'; // 禁用页面交互
            }
        };

        greetButton.addEventListener('click', function () {
            modal.style.display = 'flex'; // 显示模态框
            document.body.style.pointerEvents = 'auto'; // 允许用户与模态框交互
        });

        submitButton.addEventListener('click', function () {
            const name = nameInput.value;
            const password = passwordInput.value;
            const confirmPassword = confirmPasswordInput.value;

            // 简单的密码验证逻辑
            if (name && password && password === confirmPassword) {
                sessionStorage.setItem('username', name); // 保存用户名到 sessionStorage
                greetingMessage.textContent = `恭喜，${name}！登录成功！`;
                modal.style.display = 'none'; // 关闭模态框
                greetButton.style.display = 'none'; // 隐藏登录按钮
                document.body.style.pointerEvents = 'auto'; // 允许页面交互
            } else {
                greetingMessage.textContent = "请确保输入的密码匹配。";
            }
            nameInput.value = ''; // 清空输入框
            passwordInput.value = ''; // 清空输入框
            confirmPasswordInput.value = ''; // 清空输入框
        });

        closeButton.addEventListener('click', function () {
            modal.style.display = 'none'; // 关闭模态框
            nameInput.value = ''; // 清空输入框
            passwordInput.value = ''; // 清空输入框
            confirmPasswordInput.value = ''; // 清空输入框
        });

        // 用户输入处理
        const userInput = document.getElementById('userInput');
        const confirmInputButton = document.getElementById('confirmInputButton');
        const userInputOutput = document.getElementById('userInputOutput');

        confirmInputButton.addEventListener('click', function () {
            const inputText = userInput.value.trim(); // 获取输入的内容并去除前后空格
            if (inputText) {
                userInputOutput.textContent = inputText; // 显示用户输入的内容
                userInput.value = ''; // 清空输入框
            } else {
                alert("请输入有效内容！"); // 提示用户输入有效内容
            }
        });

        // 初始化显示第一张图片
        showImage(currentImageIndex);
    </script>
</body>
</html>
